﻿using ParkSaleSDK.Adapter;
using ParkSaleSDK.Data;
using ParkSaleSDK.Modularity;
using ReadOnlyParkSaleAdapter;
using System;
using System.Collections.Generic;
using static SystemSetting.SystemAdapters;

namespace SystemData
{
    [Serializable]
    public class PostableDiscount
    {
        public int id
        {
            get;
            set;
        }
    }


    [Serializable]
    public class HouseInfo
    {
        public Location Location
        {
            get;
            set;
        }
        public OwnedHouse House
        {
            get;
            set;
        }
    }

    [Serializable]
    public class RegisterData
    {
        public string id
        {
            get;
            set;
        }
        public string username
        {
            get;
            set;
        }
        public string password
        {
            get;
            set;
        }
        public string sign
        {
            get;
            set;
        }
        public int location
        {
            get;
            set;
        }
        public int house
        {
            get;
            set;
        }
        public int num
        {
            get;
            set;
        }
    }




    [Serializable]
    public class DiscountInfo
    {

        public DiscountInfo()
        {

        }
        IDiscount d;
        public DiscountInfo(IDiscount discount)
        {
            d = discount;
        }

        public string About
        {
            get => d != null ? d.About() : "当前系统中并无此优惠";
        }
        public string Name
        {
            get => d != null ? d.Name() : "无效优惠券";
        }
        public UserDiscount Discount
        {
            get;
            set;
        }

    }


    [Serializable]
    public class SurveyFeature
    {
        public string Name
        {
            get;
            set;
        }
        public string About
        {
            get;
            set;
        }

    }

    [Serializable]
    public class ParkingRights
    {
        public Rights Right
        {
            get;
            set;
        }
        public ParkSaleSDK.Data.Park Park
        {
            get;
            set;
        }
        public static ParkingRights[] Find(string id)
        {
            List<ParkingRights> res = new List<ParkingRights>();
            readOnly_ParkRightAdapter rightAdapter = r_Rights;
            readOnly_ParkTableAdapter parkTableAdapter = r_Park;
            var rights = rightAdapter.Find<Rights>(c_Rights.m_belong, id);
            foreach (var i in rights)
            {
                var obj = parkTableAdapter.Find<Park>(c_Parking.m_id, i.Item.ToString());
                if (obj.Length > 0)
                {
                    res.Add(new ParkingRights() { Right = i, Park = obj[0] });
                }
            }
            return res.ToArray();
        }
    }

}
